package com.whq.thrift.api.web.admin.db.config;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

public interface ConfigMapper {
	@Select("select * from t_config where conf_key=#{conf_key}")
	@Results(value = { 
			@Result(property = "conf_key", column = "conf_key"), 
			@Result(property = "conf_val", column = "conf_val"),
			@Result(property = "comment", column = "comment"), 
			@Result(property = "create_time", column = "create_time"),
			@Result(property = "update_time", column = "update_time") })
	public Config getSelectRecordByKey(@Param("conf_key") String confKey);

	@SelectProvider(type = ConfigSqlProvider.class, method = "getSelectRecrodSql")
	@Results(value = { 
			@Result(property = "conf_key", column = "conf_key"), 
			@Result(property = "conf_val", column = "conf_val"),
			@Result(property = "comment", column = "comment"),
			@Result(property = "create_time", column = "create_time"),
			@Result(property = "update_time", column = "update_time") })
	public List<Config> getSelectRecordByMap(Map<String, Object> whereParams);

	@Insert("INSERT INTO t_config (conf_key, conf_val,comment, create_time, update_time ) " +
			" VALUES (#{conf_key},#{conf_val},#{comment},#{create_time},#{update_time})")
	public void addRecord(Config config);

	@SelectProvider(type = ConfigSqlProvider.class, method = "getSelectCountSql")
	public int getSelectCountByKey(Map<String, Object> whereParams);

	@UpdateProvider(type = ConfigSqlProvider.class, method = "getUpdateSql")
	public void updRecord(Config config);

	@Delete("delete from t_config where conf_key=#{conf_key}")
	public void delRecord(@Param("conf_key") String confKey);
}
